@extends('admin.layout')
@section('body')
    <!-- 正文开始 -->
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-body">
                <!-- 表格工具栏 -->
                <form class="layui-form toolbar" id="formSearch">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">交接类型:</label>
                            <div class="layui-input-inline">
                                <x-code name="type" show-all="--所有--" code="AG"></x-code>
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">交接人:</label>
                            <div class="layui-input-inline">
                                <input name="from" class="layui-input" placeholder="姓名，用户名，电话"/>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">接收人:</label>
                            <div class="layui-input-inline">
                                <input name="to" class="layui-input" placeholder="姓名，用户名，电话"/>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">日期范围:</label>
                            <div class="layui-input-inline">
                                <input name="date_range" autocomplete="off" id="txtDateRange" class="layui-input"/>
                            </div>
                        </div>
                        <div class="layui-inline">&emsp;
                            <button class="layui-btn icon-btn" lay-filter="searchForm" lay-submit>
                                <i class="iconfont icon-ic_search"></i>@lang('common.search')
                            </button>
                        </div>
                    </div>
                </form>
                <!-- 数据表格 -->
                <table id="adminTable" lay-filter="adminTable"></table>
            </div>
        </div>
    </div>
@stop
@push('script')
    <script type="text/javascript">
        layui.use(['layer', 'form', 'table', 'util', 'admin', 'laydate'], function () {
            let listTableInc = new ListTable("{{admin_url($baseRoute.'pager')}}");
            layui.laydate.render({
                elem: '#txtDateRange'
                , range: '~' //或 range: '~' 来自定义分割字符
            });
            @auth('caller')
            listTableInc.topAction('<button class="layui-btn layui-btn-sm"><i class="layui-icon">&#xe654;</i>话务员交接</button>', function (tb) {
                SystemUtil.openUrl2({
                    title: "话务员交接",
                    area: ['600px', '600px'],
                    content: "{{admin_url($baseRoute.'caller')}}"
                });
                SystemUtil.CurrentTableInc = tb;
            });
            @endauth

            @auth('customService')
            listTableInc.topAction('<button class="layui-btn layui-btn-sm"><i class="layui-icon">&#xe654;</i>客服交接</button>', function (tb) {
                SystemUtil.openUrl2({
                    title: "客服交接",
                    area: ['600px', '600px'],
                    content: "{{admin_url($baseRoute.'custom-service')}}"
                });
                SystemUtil.CurrentTableInc = tb;
            });
            @endauth

            listTableInc.checkbox();
            listTableInc.lineNumber();
            listTableInc.column("@lang('common.id')", "id").setWidth(100);

            listTableInc.column("操作员", "name");
            listTableInc.column("交接类型", "type_text");
            listTableInc.column("交接人", "from_name").setWidth(100);
            listTableInc.column("接受人", "to_name").setWidth(100);
            listTableInc.column("交接数量", "data_count");

            listTableInc.column("新增时间", "created_at").setWithDateTime();
            listTableInc.column("修改时间", "updated_at").setWithDateTime();
            listTableInc.rowBarWidth = 140;
            listTableInc.render();
            window.listTableInc = listTableInc;
        });
    </script>
@endpush
